-
Notifications
You must be signed in to change notification settings - Fork 15.4k
release/19.x: [SCEV] Disallow simplifying phi(undef, X) to X (#115109) #118867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See the following case: ``` @GlobIntONE = global i32 0, align 4 define ptr @src() { entry: br label %for.body.peel.begin for.body.peel.begin: ; preds = %entry br label %for.body.peel for.body.peel: ; preds = %for.body.peel.begin br i1 true, label %cleanup.peel, label %cleanup.loopexit.peel cleanup.loopexit.peel: ; preds = %for.body.peel br label %cleanup.peel cleanup.peel: ; preds = %cleanup.loopexit.peel, %for.body.peel %retval.2.peel = phi ptr [ undef, %for.body.peel ], [ @GlobIntONE, %cleanup.loopexit.peel ] br i1 true, label %for.body.peel.next, label %cleanup7 for.body.peel.next: ; preds = %cleanup.peel br label %for.body.peel.next1 for.body.peel.next1: ; preds = %for.body.peel.next br label %entry.peel.newph entry.peel.newph: ; preds = %for.body.peel.next1 br label %for.body for.body: ; preds = %cleanup, %entry.peel.newph %retval.0 = phi ptr [ %retval.2.peel, %entry.peel.newph ], [ %retval.2, %cleanup ] br i1 false, label %cleanup, label %cleanup.loopexit cleanup.loopexit: ; preds = %for.body br label %cleanup cleanup: ; preds = %cleanup.loopexit, %for.body %retval.2 = phi ptr [ %retval.0, %for.body ], [ @GlobIntONE, %cleanup.loopexit ] br i1 false, label %for.body, label %cleanup7.loopexit cleanup7.loopexit: ; preds = %cleanup %retval.2.lcssa.ph = phi ptr [ %retval.2, %cleanup ] br label %cleanup7 cleanup7: ; preds = %cleanup7.loopexit, %cleanup.peel %retval.2.lcssa = phi ptr [ %retval.2.peel, %cleanup.peel ], [ %retval.2.lcssa.ph, %cleanup7.loopexit ] ret ptr %retval.2.lcssa } define ptr @tgt() { entry: br label %for.body.peel.begin for.body.peel.begin: ; preds = %entry br label %for.body.peel for.body.peel: ; preds = %for.body.peel.begin br i1 true, label %cleanup.peel, label %cleanup.loopexit.peel cleanup.loopexit.peel: ; preds = %for.body.peel br label %cleanup.peel cleanup.peel: ; preds = %cleanup.loopexit.peel, %for.body.peel %retval.2.peel = phi ptr [ undef, %for.body.peel ], [ @GlobIntONE, %cleanup.loopexit.peel ] br i1 true, label %for.body.peel.next, label %cleanup7 for.body.peel.next: ; preds = %cleanup.peel br label %for.body.peel.next1 for.body.peel.next1: ; preds = %for.body.peel.next br label %entry.peel.newph entry.peel.newph: ; preds = %for.body.peel.next1 br label %for.body for.body: ; preds = %cleanup, %entry.peel.newph br i1 false, label %cleanup, label %cleanup.loopexit cleanup.loopexit: ; preds = %for.body br label %cleanup cleanup: ; preds = %cleanup.loopexit, %for.body br i1 false, label %for.body, label %cleanup7.loopexit cleanup7.loopexit: ; preds = %cleanup %retval.2.lcssa.ph = phi ptr [ %retval.2.peel, %cleanup ] br label %cleanup7 cleanup7: ; preds = %cleanup7.loopexit, %cleanup.peel %retval.2.lcssa = phi ptr [ %retval.2.peel, %cleanup.peel ], [ %retval.2.lcssa.ph, %cleanup7.loopexit ] ret ptr %retval.2.lcssa } ``` 1. `simplifyInstruction(%retval.2.peel)` returns `@GlobIntONE`. Thus, `ScalarEvolution::createNodeForPHI` returns SCEV expr `@GlobIntONE` for `%retval.2.peel`. 2. `SimplifyIndvar::replaceIVUserWithLoopInvariant` tries to replace the use of `%retval.2.peel` in `%retval.2.lcssa.ph` with `@GlobIntONE`. 3. `simplifyLoopAfterUnroll -> simplifyLoopIVs -> SCEVExpander::expand` reuses `%retval.2.peel = phi ptr [ undef, %for.body.peel ], [ @GlobIntONE, %cleanup.loopexit.peel ]` to generate code for `@GlobIntONE`. It is incorrect. This patch disallows simplifying `phi(undef, X)` to `X` by setting `CanUseUndef` to false. Closes llvm#114879. (cherry picked from commit 0b9f1cc)
Member
|
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-llvm-analysis Author: Rose (AreaZR) ChangesSee the following case:
This patch disallows simplifying (cherry picked from commit 0b9f1cc) Patch is 22.13 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/118867.diff 16 Files Affected:
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 412cfe73d3e559..f82a3f29f93237 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -6030,7 +6030,11 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) {
if (const SCEV *S = createAddRecFromPHI(PN))
return S;
- if (Value *V = simplifyInstruction(PN, {getDataLayout(), &TLI, &DT, &AC}))
+ // We do not allow simplifying phi (undef, X) to X here, to avoid reusing the
+ // phi node for X.
+ if (Value *V = simplifyInstruction(
+ PN, {getDataLayout(), &TLI, &DT, &AC, /*CtxI=*/nullptr,
+ /*UseInstrInfo=*/true, /*CanUseUndef=*/false}))
return getSCEV(V);
if (const SCEV *S = createNodeFromSelectLikePHI(PN))
diff --git a/llvm/test/Transforms/IndVarSimplify/invalidate-modified-lcssa-phi.ll b/llvm/test/Transforms/IndVarSimplify/invalidate-modified-lcssa-phi.ll
index 856fc376204995..0538c1c64de34d 100644
--- a/llvm/test/Transforms/IndVarSimplify/invalidate-modified-lcssa-phi.ll
+++ b/llvm/test/Transforms/IndVarSimplify/invalidate-modified-lcssa-phi.ll
@@ -48,13 +48,14 @@ define i8 @test_pr52023(i1 %c.1, i1 %c.2) {
; CHECK-NEXT: br label [[LOOP_1:%.*]]
; CHECK: loop.1:
; CHECK-NEXT: [[INC79:%.*]] = phi i8 [ [[TMP0:%.*]], [[LOOP_1_LATCH:%.*]] ], [ 0, [[ENTRY:%.*]] ]
-; CHECK-NEXT: [[TMP0]] = add i8 [[INC79]], 1
+; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[INC79]], 1
; CHECK-NEXT: br label [[LOOP_2:%.*]]
; CHECK: loop.2:
; CHECK-NEXT: br i1 [[C_1:%.*]], label [[LOOP_2_LATCH:%.*]], label [[LOOP_1_LATCH]]
; CHECK: loop.2.latch:
; CHECK-NEXT: br label [[LOOP_1_LATCH]]
; CHECK: loop.1.latch:
+; CHECK-NEXT: [[TMP0]] = phi i8 [ [[TMP1]], [[LOOP_2_LATCH]] ], [ undef, [[LOOP_2]] ]
; CHECK-NEXT: br i1 [[C_2:%.*]], label [[EXIT:%.*]], label [[LOOP_1]]
; CHECK: exit:
; CHECK-NEXT: [[INC_LCSSA_LCSSA:%.*]] = phi i8 [ [[TMP0]], [[LOOP_1_LATCH]] ]
diff --git a/llvm/test/Transforms/IndVarSimplify/no-iv-rewrite.ll b/llvm/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
index 579b8536cedf03..5339468fe8036b 100644
--- a/llvm/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
+++ b/llvm/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
@@ -260,11 +260,13 @@ define void @identityphi(i32 %limit) nounwind {
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
-; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[CONTROL:%.*]]
+; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[CONTROL:%.*]] ]
+; CHECK-NEXT: br i1 undef, label [[IF_THEN:%.*]], label [[CONTROL]]
; CHECK: if.then:
; CHECK-NEXT: br label [[CONTROL]]
; CHECK: control:
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 0, [[LIMIT:%.*]]
+; CHECK-NEXT: [[IV_NEXT]] = phi i32 [ [[IV]], [[LOOP]] ], [ undef, [[IF_THEN]] ]
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[IV_NEXT]], [[LIMIT:%.*]]
; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
; CHECK: exit:
; CHECK-NEXT: ret void
diff --git a/llvm/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll b/llvm/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll
index c4aa6c7725d411..f9582fb4a35b14 100644
--- a/llvm/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll
+++ b/llvm/test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll
@@ -156,29 +156,29 @@ define fastcc void @test3(ptr nocapture %u) nounwind uwtable ssp {
; CHECK: for.inc8.us.i:
; CHECK-NEXT: br i1 true, label [[MESHBB1_LOOPEXIT:%.*]], label [[MESHBB:%.*]]
; CHECK: for.body3.us.i:
-; CHECK-NEXT: [[INDVARS_IV_I_SV_PHI:%.*]] = phi i64 [ [[INDVARS_IV_NEXT_I:%.*]], [[MESHBB]] ], [ 0, [[FOR_BODY3_LR_PH_US_I:%.*]] ]
+; CHECK-NEXT: [[TMP:%.*]] = phi i32 [ [[LSR_IV_NEXT:%.*]], [[MESHBB]] ], [ [[TMP3:%.*]], [[FOR_BODY3_LR_PH_US_I:%.*]] ]
+; CHECK-NEXT: [[SCEVGEP:%.*]] = phi ptr [ [[SCEVGEP1:%.*]], [[MESHBB]] ], [ [[U:%.*]], [[FOR_BODY3_LR_PH_US_I]] ]
; CHECK-NEXT: [[OPQ_SA_CALC12:%.*]] = sub i32 undef, 227
-; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[LSR_IV:%.*]], [[INDVARS_IV_I_SV_PHI]]
-; CHECK-NEXT: [[TMP:%.*]] = trunc i64 [[TMP0]] to i32
; CHECK-NEXT: [[MUL_I_US_I:%.*]] = mul nsw i32 0, [[TMP]]
-; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[INDVARS_IV_I_SV_PHI]], 3
-; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr [[U:%.*]], i64 [[TMP1]]
; CHECK-NEXT: [[TMP2:%.*]] = load double, ptr [[SCEVGEP]], align 8
; CHECK-NEXT: br i1 undef, label [[FOR_INC8_US_I:%.*]], label [[MESHBB]]
; CHECK: for.body3.lr.ph.us.i.loopexit:
-; CHECK-NEXT: [[LSR_IV_NEXT:%.*]] = add i64 [[LSR_IV]], 1
; CHECK-NEXT: br label [[FOR_BODY3_LR_PH_US_I]]
; CHECK: for.body3.lr.ph.us.i:
-; CHECK-NEXT: [[LSR_IV]] = phi i64 [ [[LSR_IV_NEXT]], [[FOR_BODY3_LR_PH_US_I_LOOPEXIT:%.*]] ], [ undef, [[MESHBB1]] ]
+; CHECK-NEXT: [[LSR_IV:%.*]] = phi i64 [ undef, [[MESHBB1]] ], [ [[INDVARS_IV8_I_SV_PHI24:%.*]], [[FOR_BODY3_LR_PH_US_I_LOOPEXIT:%.*]] ]
; CHECK-NEXT: [[ARRAYIDX_US_I:%.*]] = getelementptr inbounds double, ptr undef, i64 [[LSR_IV]]
+; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[LSR_IV]], 1
+; CHECK-NEXT: [[TMP3]] = trunc i64 [[LSR_IV]] to i32
; CHECK-NEXT: br label [[FOR_BODY3_US_I:%.*]]
; CHECK: for.inc8.us.i2:
; CHECK-NEXT: unreachable
; CHECK: eval_At_times_u.exit:
; CHECK-NEXT: ret void
; CHECK: meshBB:
+; CHECK-NEXT: [[INDVARS_IV8_I_SV_PHI24]] = phi i64 [ undef, [[FOR_BODY3_US_I]] ], [ [[TMP1]], [[FOR_INC8_US_I]] ]
; CHECK-NEXT: [[MESHSTACKVARIABLE_PHI:%.*]] = phi i32 [ [[OPQ_SA_CALC12]], [[FOR_BODY3_US_I]] ], [ undef, [[FOR_INC8_US_I]] ]
-; CHECK-NEXT: [[INDVARS_IV_NEXT_I]] = add i64 [[INDVARS_IV_I_SV_PHI]], 1
+; CHECK-NEXT: [[SCEVGEP1]] = getelementptr i8, ptr [[SCEVGEP]], i64 8
+; CHECK-NEXT: [[LSR_IV_NEXT]] = add i32 [[TMP]], 1
; CHECK-NEXT: br i1 true, label [[FOR_BODY3_LR_PH_US_I_LOOPEXIT]], label [[FOR_BODY3_US_I]]
; CHECK: meshBB1.loopexit:
; CHECK-NEXT: br label [[MESHBB1]]
diff --git a/llvm/test/Transforms/LoopUnroll/pr114879.ll b/llvm/test/Transforms/LoopUnroll/pr114879.ll
new file mode 100644
index 00000000000000..4cd91a0f6c09f7
--- /dev/null
+++ b/llvm/test/Transforms/LoopUnroll/pr114879.ll
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S -passes=loop-unroll-full -unroll-full-max-count=1 %s | FileCheck %s
+
+@GlobIntONE = global i32 0, align 4
+
+; Make sure we don't reuse the phi (undef, X) for X.
+
+define ptr @test() {
+; CHECK-LABEL: define ptr @test() {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: br label %[[FOR_BODY_PEEL_BEGIN:.*]]
+; CHECK: [[FOR_BODY_PEEL_BEGIN]]:
+; CHECK-NEXT: br label %[[FOR_BODY_PEEL:.*]]
+; CHECK: [[FOR_BODY_PEEL]]:
+; CHECK-NEXT: br i1 true, label %[[CLEANUP_PEEL:.*]], label %[[CLEANUP_LOOPEXIT_PEEL:.*]]
+; CHECK: [[CLEANUP_LOOPEXIT_PEEL]]:
+; CHECK-NEXT: br label %[[CLEANUP_PEEL]]
+; CHECK: [[CLEANUP_PEEL]]:
+; CHECK-NEXT: [[RETVAL_2_PEEL:%.*]] = phi ptr [ undef, %[[FOR_BODY_PEEL]] ], [ @GlobIntONE, %[[CLEANUP_LOOPEXIT_PEEL]] ]
+; CHECK-NEXT: br i1 true, label %[[FOR_BODY_PEEL_NEXT:.*]], label %[[CLEANUP2:.*]]
+; CHECK: [[FOR_BODY_PEEL_NEXT]]:
+; CHECK-NEXT: br label %[[FOR_BODY_PEEL_NEXT1:.*]]
+; CHECK: [[FOR_BODY_PEEL_NEXT1]]:
+; CHECK-NEXT: br label %[[ENTRY_PEEL_NEWPH:.*]]
+; CHECK: [[ENTRY_PEEL_NEWPH]]:
+; CHECK-NEXT: br label %[[FOR_BODY:.*]]
+; CHECK: [[FOR_BODY]]:
+; CHECK-NEXT: br i1 false, label %[[CLEANUP:.*]], label %[[CLEANUP_LOOPEXIT:.*]]
+; CHECK: [[CLEANUP_LOOPEXIT]]:
+; CHECK-NEXT: br label %[[CLEANUP]]
+; CHECK: [[CLEANUP]]:
+; CHECK-NEXT: br i1 false, label %[[FOR_BODY]], label %[[CLEANUP2_LOOPEXIT:.*]], !llvm.loop [[LOOP0:![0-9]+]]
+; CHECK: [[CLEANUP2_LOOPEXIT]]:
+; CHECK-NEXT: [[RETVAL_2_LCSSA_PH:%.*]] = phi ptr [ @GlobIntONE, %[[CLEANUP]] ]
+; CHECK-NEXT: br label %[[CLEANUP2]]
+; CHECK: [[CLEANUP2]]:
+; CHECK-NEXT: [[RETVAL_2_LCSSA:%.*]] = phi ptr [ [[RETVAL_2_PEEL]], %[[CLEANUP_PEEL]] ], [ [[RETVAL_2_LCSSA_PH]], %[[CLEANUP2_LOOPEXIT]] ]
+; CHECK-NEXT: ret ptr [[RETVAL_2_LCSSA]]
+;
+entry:
+ br label %for.body
+
+for.body:
+ %retval.0 = phi ptr [ undef, %entry ], [ %retval.2, %cleanup ]
+ %cmp1.not = phi i1 [ true, %entry ], [ false, %cleanup ]
+ br i1 %cmp1.not, label %cleanup, label %cleanup.loopexit
+
+cleanup.loopexit:
+ br label %cleanup
+
+cleanup:
+ %retval.2 = phi ptr [ %retval.0, %for.body ], [ @GlobIntONE, %cleanup.loopexit ]
+ br i1 %cmp1.not, label %for.body, label %cleanup2
+
+cleanup2:
+ %retval.2.lcssa = phi ptr [ %retval.2, %cleanup ]
+ ret ptr %retval.2.lcssa
+}
+;.
+; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]]}
+; CHECK: [[META1]] = !{!"llvm.loop.peeled.count", i32 1}
+;.
diff --git a/llvm/test/Transforms/LoopVectorize/uniform-blend.ll b/llvm/test/Transforms/LoopVectorize/uniform-blend.ll
index c9fc8beb006d9b..ecc1ae817b6874 100644
--- a/llvm/test/Transforms/LoopVectorize/uniform-blend.ll
+++ b/llvm/test/Transforms/LoopVectorize/uniform-blend.ll
@@ -14,9 +14,9 @@ define void @blend_uniform_iv_trunc(i1 %c) {
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
; CHECK-NEXT: [[TMP0:%.*]] = trunc i64 [[INDEX]] to i16
; CHECK-NEXT: [[TMP1:%.*]] = add i16 [[TMP0]], 0
-; CHECK-NEXT: [[PREDPHI:%.*]] = select i1 [[C]], i16 [[TMP1]], i16 undef
-; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i16 [[PREDPHI]]
-; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i16, ptr [[TMP2]], i32 0
+; CHECK-NEXT: [[TMP6:%.*]] = select i1 [[C]], i16 [[TMP1]], i16 poison
+; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i16 [[TMP6]]
+; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i16, ptr [[TMP7]], i32 0
; CHECK-NEXT: store <4 x i16> zeroinitializer, ptr [[TMP3]], align 2
; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[INDEX_NEXT]], 32
@@ -33,7 +33,7 @@ define void @blend_uniform_iv_trunc(i1 %c) {
; CHECK: [[LOOP_NEXT]]:
; CHECK-NEXT: br label %[[LOOP_LATCH]]
; CHECK: [[LOOP_LATCH]]:
-; CHECK-NEXT: [[BLEND:%.*]] = phi i16 [ undef, %[[LOOP_HEADER]] ], [ [[IV_TRUNC_2]], %[[LOOP_NEXT]] ]
+; CHECK-NEXT: [[BLEND:%.*]] = phi i16 [ poison, %[[LOOP_HEADER]] ], [ [[IV_TRUNC_2]], %[[LOOP_NEXT]] ]
; CHECK-NEXT: [[DST_PTR:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i16 [[BLEND]]
; CHECK-NEXT: store i16 0, ptr [[DST_PTR]], align 2
; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
@@ -54,7 +54,7 @@ loop.next: ; preds = %loop.header
br label %loop.latch
loop.latch: ; preds = %loop.next, %loop.header
- %blend = phi i16 [ undef, %loop.header ], [ %iv.trunc.2, %loop.next ]
+ %blend = phi i16 [ poison, %loop.header ], [ %iv.trunc.2, %loop.next ]
%dst.ptr = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i16 %blend
store i16 0, ptr %dst.ptr
%iv.next = add nuw nsw i64 %iv, 1
@@ -75,9 +75,9 @@ define void @blend_uniform_iv(i1 %c) {
; CHECK: [[VECTOR_BODY]]:
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[INDEX]], 0
-; CHECK-NEXT: [[PREDPHI:%.*]] = select i1 [[C]], i64 [[TMP0]], i64 undef
-; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 [[PREDPHI]]
-; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i16, ptr [[TMP1]], i32 0
+; CHECK-NEXT: [[TMP6:%.*]] = select i1 [[C]], i64 [[TMP0]], i64 poison
+; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 [[TMP6]]
+; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i16, ptr [[TMP7]], i32 0
; CHECK-NEXT: store <4 x i16> zeroinitializer, ptr [[TMP2]], align 2
; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i64 [[INDEX_NEXT]], 32
@@ -93,7 +93,7 @@ define void @blend_uniform_iv(i1 %c) {
; CHECK: [[LOOP_NEXT]]:
; CHECK-NEXT: br label %[[LOOP_LATCH]]
; CHECK: [[LOOP_LATCH]]:
-; CHECK-NEXT: [[BLEND:%.*]] = phi i64 [ undef, %[[LOOP_HEADER]] ], [ [[IV]], %[[LOOP_NEXT]] ]
+; CHECK-NEXT: [[BLEND:%.*]] = phi i64 [ poison, %[[LOOP_HEADER]] ], [ [[IV]], %[[LOOP_NEXT]] ]
; CHECK-NEXT: [[DST_PTR:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 [[BLEND]]
; CHECK-NEXT: store i16 0, ptr [[DST_PTR]], align 2
; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
@@ -114,7 +114,7 @@ loop.next: ; preds = %loop.header
br label %loop.latch
loop.latch: ; preds = %loop.next, %loop.header
- %blend = phi i64 [ undef, %loop.header ], [ %iv, %loop.next ]
+ %blend = phi i64 [ poison, %loop.header ], [ %iv, %loop.next ]
%dst.ptr = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 %blend
store i16 0, ptr %dst.ptr
%iv.next = add nuw nsw i64 %iv, 1
diff --git a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
index a6a5ffda3cb706..75e138cb3e8446 100644
--- a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
+++ b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp
@@ -139,7 +139,7 @@ TEST_F(ScalarEvolutionsTest, SimplifiedPHI) {
auto *Ty = Type::getInt32Ty(Context);
auto *PN = PHINode::Create(Ty, 2, "", &*LoopBB->begin());
PN->addIncoming(Constant::getNullValue(Ty), EntryBB);
- PN->addIncoming(UndefValue::get(Ty), LoopBB);
+ PN->addIncoming(PoisonValue::get(Ty), LoopBB);
ScalarEvolution SE = buildSE(*F);
auto *S1 = SE.getSCEV(PN);
auto *S2 = SE.getSCEV(PN);
diff --git a/polly/test/CodeGen/OpenMP/floord-as-argument-to-subfunction.ll b/polly/test/CodeGen/OpenMP/floord-as-argument-to-subfunction.ll
index 9eb7f5f2a5e9fd..7177ae01f0754d 100644
--- a/polly/test/CodeGen/OpenMP/floord-as-argument-to-subfunction.ll
+++ b/polly/test/CodeGen/OpenMP/floord-as-argument-to-subfunction.ll
@@ -20,9 +20,9 @@ for.cond39.for.cond66.preheader.loopexit67_crit_edge: ; preds = %for.body42
br label %for.cond66.preheader
for.cond66.preheader: ; preds = %for.cond39.for.cond66.preheader.loopexit67_crit_edge, %if.end
- %rawout1.3.ph = phi ptr [ %add.ptr62.lcssa, %for.cond39.for.cond66.preheader.loopexit67_crit_edge ], [ undef, %if.end ]
+ %rawout1.3.ph = phi ptr [ %add.ptr62.lcssa, %for.cond39.for.cond66.preheader.loopexit67_crit_edge ], [ poison, %if.end ]
%sb.3.ph = phi i32 [ 0, %for.cond39.for.cond66.preheader.loopexit67_crit_edge ], [ 0, %if.end ]
- %tspnt.3.ph = phi ptr [ undef, %for.cond39.for.cond66.preheader.loopexit67_crit_edge ], [ %tsOut, %if.end ]
+ %tspnt.3.ph = phi ptr [ poison, %for.cond39.for.cond66.preheader.loopexit67_crit_edge ], [ %tsOut, %if.end ]
br label %for.cond69.preheader
for.body42: ; preds = %if.end
@@ -31,12 +31,12 @@ for.body42: ; preds = %if.end
for.cond69.preheader: ; preds = %for.end76, %for.cond66.preheader
%tspnt.375 = phi ptr [ %incdec.ptr79, %for.end76 ], [ %tspnt.3.ph, %for.cond66.preheader ]
%sb.374 = phi i32 [ %inc78, %for.end76 ], [ %sb.3.ph, %for.cond66.preheader ]
- %rawout1.373 = phi ptr [ undef, %for.end76 ], [ %rawout1.3.ph, %for.cond66.preheader ]
+ %rawout1.373 = phi ptr [ poison, %for.end76 ], [ %rawout1.3.ph, %for.cond66.preheader ]
br label %for.body71
for.body71: ; preds = %for.body71, %for.cond69.preheader
%indvars.iv = phi i64 [ 0, %for.cond69.preheader ], [ %indvars.iv.next, %for.body71 ]
- %rawout1.469 = phi ptr [ %rawout1.373, %for.cond69.preheader ], [ undef, %for.body71 ]
+ %rawout1.469 = phi ptr [ %rawout1.373, %for.cond69.preheader ], [ poison, %for.body71 ]
%0 = load i64, ptr %rawout1.469, align 8
%1 = shl nsw i64 %indvars.iv, 5
%arrayidx73 = getelementptr inbounds double, ptr %tspnt.375, i64 %1
diff --git a/polly/test/CodeGen/inner_scev_sdiv_2.ll b/polly/test/CodeGen/inner_scev_sdiv_2.ll
index 74b914d1d87ad0..33233fe2fdf176 100644
--- a/polly/test/CodeGen/inner_scev_sdiv_2.ll
+++ b/polly/test/CodeGen/inner_scev_sdiv_2.ll
@@ -34,7 +34,7 @@ for.cond.60.preheader: ; preds = %for.body.51, %for.c
ret void
for.body.51: ; preds = %for.body.51, %for.body.51.lr.ph
- %indvars.iv86 = phi i64 [ %2, %for.body.51.lr.ph ], [ undef, %for.body.51 ]
+ %indvars.iv86 = phi i64 [ %2, %for.body.51.lr.ph ], [ poison, %for.body.51 ]
%arrayidx53 = getelementptr inbounds float, ptr %0, i64 %indvars.iv86
%3 = load float, ptr %arrayidx53, align 4
%mul56 = fmul float %3, undef
diff --git a/polly/test/CodeGen/inner_scev_sdiv_3.ll b/polly/test/CodeGen/inner_scev_sdiv_3.ll
index 33440457bd466a..a8c626347efe9a 100644
--- a/polly/test/CodeGen/inner_scev_sdiv_3.ll
+++ b/polly/test/CodeGen/inner_scev_sdiv_3.ll
@@ -36,7 +36,7 @@ end:
ret i64 %div44.m
for.body.51: ; preds = %for.body.51, %for.body.51.lr.ph
- %indvars.iv86 = phi i64 [ %2, %for.body.51.lr.ph ], [ undef, %for.body.51 ]
+ %indvars.iv86 = phi i64 [ %2, %for.body.51.lr.ph ], [ poison, %for.body.51 ]
%arrayidx53 = getelementptr inbounds float, ptr %0, i64 %indvars.iv86
%3 = load float, ptr %arrayidx53, align 4
%mul56 = fmul float %3, undef
diff --git a/polly/test/CodeGen/non-affine-phi-node-expansion.ll b/polly/test/CodeGen/non-affine-phi-node-expansion.ll
index 8fd8cc14124b07..1b6802f1a4c35c 100644
--- a/polly/test/CodeGen/non-affine-phi-node-expansion.ll
+++ b/polly/test/CodeGen/non-affine-phi-node-expansion.ll
@@ -31,7 +31,7 @@ bb1: ; preds = %bb
br label %bb2
bb2: ; preds = %bb1, %bb
- %tmp = phi i1 [ true, %bb ], [ undef, %bb1 ]
+ %tmp = phi i1 [ true, %bb ], [ poison, %bb1 ]
br label %bb3
bb3: ; preds = %bb13, %bb2
diff --git a/polly/test/CodeGen/phi-defined-before-scop.ll b/polly/test/CodeGen/phi-defined-before-scop.ll
index f08322281d3c32..23612061156d99 100644
--- a/polly/test/CodeGen/phi-defined-before-scop.ll
+++ b/polly/test/CodeGen/phi-defined-before-scop.ll
@@ -19,7 +19,7 @@ bb:
br label %bb1
bb1: ; preds = %bb6, %bb
- %tmp2 = phi ptr [ %tmp7, %bb6 ], [ undef, %bb ]
+ %tmp2 = phi ptr [ %tmp7, %bb6 ], [ poison, %bb ]
%tmp = load ptr, ptr @global, align 8, !tbaa !1
br label %bb3
@@ -31,7 +31,7 @@ bb5: ; preds = %bb3
br label %bb6
bb6: ; preds = %bb5, %bb3
- %tmp7 = phi ptr [ %tmp2, %bb3 ], [ undef, %bb5 ]
+ %tmp7 = phi ptr [ %tmp2, %bb3 ], [ poison, %bb5 ]
br i1 undef, label %bb8, label %bb1
bb8: ; preds = %bb6
diff --git a/polly/test/CodeGen/scop_expander_insert_point.ll b/polly/test/CodeGen/scop_expander_insert_point.ll
index 92f2772155ee5a..fd73132258ddc3 100644
--- a/polly/test/CodeGen/scop_expander_insert_point.ll
+++ b/polly/test/CodeGen/scop_expander_insert_point.ll
@@ -27,8 +27,8 @@ for.body17.lr.ph: ; preds = %for.end22, %for.con
br label %for.body17
for.body17: ; preds = %for.body17, %for.body17.lr.ph
- %outvalue.141 = phi i64 [ undef, %for.body17.lr.ph ], [ %add19, %for.body17 ]
- %inptr.040 = phi ptr [ %add.ptr, %for.body17.lr.ph ], [ undef, %for.body17 ]
+ %outvalue.141 = phi i64 [ poison, %for.body17.lr.ph ], [ %add19, %for.body17 ]
+ %inptr.040 = phi ptr [ %add.ptr, %for.body17.lr.ph ], [ poison, %for.body17 ]
%1 = load i8, ptr %inptr.040
%add19 = mul nsw i64 0, %outvalue.141
br i1 false, label %for.body17, label %for.end22
diff --git a/polly/test/CodeGen/stack-overflow-in-load-hoisting.ll b/polly/test/CodeGen/stack-overflow-in-load-hoisting.ll
index cb9d9a2ec49253..b49c4e12fe11a6 100644
--- a/po...
[truncated]
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See the following case:
simplifyInstruction(%retval.2.peel)returns@GlobIntONE. Thus,ScalarEvolution::createNodeForPHIreturns SCEV expr@GlobIntONEfor%retval.2.peel.SimplifyIndvar::replaceIVUserWithLoopInvarianttries to replace the use of%retval.2.peelin%retval.2.lcssa.phwith@GlobIntONE.simplifyLoopAfterUnroll -> simplifyLoopIVs -> SCEVExpander::expandreuses%retval.2.peel = phi ptr [ undef, %for.body.peel ], [ @GlobIntONE, %cleanup.loopexit.peel ]to generate code for@GlobIntONE. It is incorrect.This patch disallows simplifying
phi(undef, X)toXby settingCanUseUndefto false.Closes #114879.
(cherry picked from commit 0b9f1cc)